<template>
  <div class="app-container">

    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="几居室" prop="strategyHabitable">
        <el-input
          v-model="queryParams.strategyHabitable"
          placeholder="请输入几居室"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="方式" prop="fangshi">
        <el-input
          v-model="queryParams.fangshi"
          placeholder="请输入方式(1半包  2全包)"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="视频URL" prop="shipinUrl">-->
<!--        <el-input-->
<!--          v-model="queryParams.shipinUrl"-->
<!--          placeholder="请输入视频URL"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="类型" prop="strategyType">
        <el-select v-model="queryParams.strategyType" placeholder="请选择1整屋案例  2 3D设计" clearable size="small">
          <el-option label="1整屋案例  2 3D设计" value="" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-col>
      <!--<el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
        >删除</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:strategy:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          size="mini"
          @click="handlevr"
        >查看VR</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          size="mini"
          @click="handlepic"
        >查看轮播图片</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="strategyList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="施工攻略ID" align="center" prop="constructionStrategyId" />
<!--      <el-table-column label="店铺ID" align="center" prop="constructionStrategySupplier" />-->
<!--      <el-table-column label="施工攻略标题" align="center" prop="constructionStrategyTitle" />-->
<!--      <el-table-column label="点赞数" align="center" prop="constructionStrategyGood" />-->
<!--      <el-table-column label="收藏数" align="center" prop="constructionStrategyCollection" />-->
<!--      <el-table-column label="回复量" align="center" prop="constructionStrategyComment" />-->
<!--      <el-table-column label="发布时间" align="center" prop="constructionStrategyTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.constructionStrategyTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="最后修改时间" align="center" prop="modifiedTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.modifiedTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="首页主题" align="center" prop="strategyTheme" :show-overflow-tooltip="true" />
<!--      <el-table-column label="用户ID" align="center" prop="userId" />-->
      <!--<el-table-column label="几居室" align="center" prop="strategyHabitable" />
      <el-table-column label="什么年代" align="center" prop="strategyName" />
      <el-table-column label="多少米" align="center" prop="meters" />
      <el-table-column label="多少钱" align="center" prop="price" />
      <el-table-column label="风格" align="center" prop="strategyStyle" />
      <el-table-column label="预计多少钱" align="center" prop="priceYusuan" />
      <el-table-column label="方式" align="center" prop="fangshi" />-->
      <el-table-column label="视频URL" align="center" prop="shipinUrl" :show-overflow-tooltip="true" />
      <el-table-column label="类型" align="center" prop="strategyType" />
      <el-table-column label="首页图片" width="200" align="center" prop="strategyZhutuUrl" >
        <template slot-scope="scope">
          <el-image
            style="width: 100px; height: 100px"
            :src="scope.row.strategyZhutuUrl"
            @click="getBigCertificateUrl(scope.row)"
          >
          </el-image>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>

          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleAddvr(scope.row)"
          >新增vr</el-button>

          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleAddPic(scope.row)"
          >新增轮播图片</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />



    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-row>

        <el-form-item label="店铺" prop="constructionStrategySupplier">
          <el-select v-model="form.constructionStrategySupplier">
            <el-option v-for="supplier in this.supplierList" :key="supplier.supplierId" :value="supplier.supplierId" :label="supplier.shopsName"></el-option>
          </el-select>
        </el-form-item>

<!--        <el-col :span="24">-->
          <el-form-item label="内容">
<!--            <editor v-model="form.constructionStrategyTitle" :min-height="192"/>-->
            <QuillEditor v-model="form.constructionStrategyTitle" @getChildrenStatus="getChildrenStatus"></QuillEditor>
          </el-form-item>
<!--        </el-col>-->
<!--      <el-col :span="24">-->
        <el-form-item label="首页主题" prop="strategyTheme">
          <el-input v-model="form.strategyTheme" placeholder="请输入首页主题" />
        </el-form-item>
<!--      </el-col>-->


<!--        <el-col :span="12">-->
<!--          <el-form-item label="视频URL" prop="shipinUrl">-->
<!--            <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">-->
<!--              <el-button size="small" type="primary">点击上传</el-button>-->
<!--              <div slot="tip" class="el-upload__tip">视频不能大于50M</div>-->
<!--            </el-upload>-->
<!--          </el-form-item>-->

        <el-form-item label="视频URL" prop="shipinUrl">
          <el-upload
            class="upload-demo"
            action="#"
            :before-upload="beforeUpload2"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :file-list="fileList2"
            :limit="1"
            list-type="picture">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传mp4文件，且不超过500kb，注：不支持多文件</div>
          </el-upload>
        </el-form-item>

<!--        </el-col>-->

<!--        <el-col :span="12">-->
          <el-form-item label="首页图片" prop="strategyZhutuUrl">
            <el-upload
              class="upload-demo"
              :http-request="upload"
              action="aaa"
              accept=".jpg,.png"
              :limit="1"
              :file-list="InfoImgList"
              :on-remove="handleRemoveInfoImage"
              :before-remove="beforeRemoveInfo"
              :on-error="handleError"
              ref="upload">
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">仅支持jpg,png格式,以最新上传为准</div>
            </el-upload>
          </el-form-item>
<!--        </el-col>-->



<!--        <el-col :span="6">-->
          <!--<el-form-item label="户型" prop="strategyHabitable">
            <el-input v-model="form.strategyHabitable" placeholder="请输入几居室" >
              <template slot="append">室</template>
            </el-input>
          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="6">-->
          <!--<el-form-item label="装修风格" prop="strategyName">
            <el-input v-model="form.strategyName" placeholder="请输入什么年代" />
          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="6">-->
          <!--<el-form-item label="多少米" prop="meters">
            <el-input v-model="form.meters" placeholder="请输入多少米" >
              <template slot="append">㎡</template>
            </el-input>
          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="6">-->
          <!--<el-form-item label="多少钱" prop="price">
            <el-input v-model="form.price" placeholder="请输入多少钱" >
              <template slot="append">万元</template>
            </el-input>
          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="6"></el-col>-->
<!--        <el-col :span="6"></el-col>-->



        <!--<el-form-item label="简约型" prop="strategyStyle">
          <el-input v-model="form.strategyStyle" placeholder="请输入风格" />
        </el-form-item>
        <el-form-item label="预计多少钱" prop="priceYusuan">
          <el-input v-model="form.priceYusuan" placeholder="请输入预计多少钱" >
            <template slot="append">万元</template>
          </el-input>
        </el-form-item>
        <el-form-item label="方式" prop="fangshi">
          <el-select v-model="form.fangshi" placeholder="请输入方式(1半包 2整包)">
            <el-option label="半包" value="半包" />
            <el-option label="整包" value="整包" />
          </el-select>
        </el-form-item>-->

        <el-form-item label="类型" prop="strategyType">
          <el-select v-model="form.strategyType" placeholder="请选择整屋案例或视频案例">
            <el-option label="图文专区" value="1" />
            <el-option label="视频专区" value="5" />
          </el-select>
        </el-form-item>

      </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 添加或修改施工攻略全景VR对话框 -->
    <el-dialog :title="titlevr" :visible.sync="openvr" width="500px" append-to-body>
      <el-form ref="form" :model="formvr" :rules="rulesvr" label-width="100px">

        <el-form-item label="VR首页图" prop="vrShouyeUrl">
<!--          <el-input v-model="form.vrShouyeUrl" placeholder="请输入VR首页图" />-->
              <el-upload
                class="upload-demo"
                :http-request="uploadVR"
                action="aaa"
                accept=".jpg,.png"
                :limit="1"
                :file-list="InfoImgListVR"
                :on-remove="handleRemoveInfoImageVR"
                :before-remove="beforeRemoveInfoVR"
                :on-error="handleError"
                ref="uploadVR">
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">仅支持jpg,png格式,以最新上传为准</div>
              </el-upload>

        </el-form-item>

        <el-form-item label="VR主题" prop="vrZhuti">
          <el-input v-model="formvr.vrZhuti" placeholder="请输入VR主题" />
        </el-form-item>

        <el-form-item label="VR全景地址" prop="vrUrl">
          <el-input v-model="formvr.vrUrl" placeholder="请输入VR全景地址" />
        </el-form-item>


      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormvr">确 定</el-button>
        <el-button @click="cancelvr">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="titlechavr" :visible.sync="openchavr" width="1000px" append-to-body>
      <el-table v-loading="loading" :data="avrList" @selection-change="handleSelectionChange">
        <el-table-column label="VR全景ID" align="center" prop="vrId" />
<!--        <el-table-column label="施工攻略ID" align="center" prop="constructionStrategyId" />-->
<!--        <el-table-column label="用户ID" align="center" prop="userId" />-->
<!--        <el-table-column label="0未审核  1已审核" align="center" prop="state" />-->
        <el-table-column label="VR全景地址" align="center" prop="vrUrl" :show-overflow-tooltip="true" >
          <template slot-scope="scope">
            <a :href="scope.row.vrUrl" target="_blank" rel="noopener" >{{scope.row.vrUrl}}</a>
          </template>
        </el-table-column>
        <el-table-column label="VR首页图" align="center" prop="vrShouyeUrl" :show-overflow-tooltip="true" />
        <el-table-column label="VR主题" align="center" prop="vrZhuti" :show-overflow-tooltip="true" />


      </el-table>

      <pagination
        v-show="totalvr>0"
        :total="totalvr"
        :page.sync="queryParamsvr.pageNum"
        :limit.sync="queryParamsvr.pageSize"
        @pagination="getList"
      />
    </el-dialog>



    <el-dialog :title="titlePic" :visible.sync="openPic" width="500px" append-to-body>
      <el-form ref="form" :model="formPic" label-width="80px">
        <el-form-item label="图片URL" prop="pictureUrl">
<!--          <el-input v-model="formPic.pictureUrl" placeholder="请输入图片URL" />-->
          <el-upload
            class="upload-demo"
            :http-request="uploadpic"
            action="aaa"
            accept=".jpg,.png"
            :limit="1"
            :file-list="InfoImgListpic"
            :on-remove="handleRemoveInfoImagepic"
            :before-remove="beforeRemoveInfopic"
            :on-error="handleErrorpic"
            ref="uploadpic">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">仅支持jpg,png格式,以最新上传为准</div>
          </el-upload>

        </el-form-item>
<!--        <el-form-item label="施工攻略ID" prop="constructionStrategyId">-->
<!--          <el-input v-model="formPic.constructionStrategyId" placeholder="请输入施工攻略ID" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="用户ID" prop="userId">-->
<!--          <el-input v-model="formPic.userId" placeholder="请输入用户ID" />-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormPic">确 定</el-button>
        <el-button @click="cancelPic">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="titlechapic" :visible.sync="openchapic" width="1000px" append-to-body>
      <strategy-pic></strategy-pic>
    </el-dialog>
  </div>
</template>

<script>
  import { upVideo,listStrategy, getStrategy, delStrategy, addStrategy, updateStrategy, exportStrategy,uploadImage,uploadVideo,listVr,addVr,uploadImageVr,selectSupplierList } from "@/api/construction/strategy";
  import { listPicture, getPicture, delPicture, addPicture, updatePicture, uploadImagepic } from "@/api/construction/strategypic";
  import Editor from '@/components/Editor'
  import QuillEditor from '@/components/Quill-editor';
  export default {
  name: "Strategy",
    components: {
      Editor,QuillEditor,
      StrategyPic:()=> import('@/views/construction/strategy/strategy_pic.vue'),

    },
    data(){
      return{
        fileList2: [],
        // 店铺列表
        supplierList:[],
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        totalvr: 0,
        // 施工攻略表格数据
        strategyList: [],
        avrList:[],
        // 弹出层标题
        title: "",
        titlePic: "",
        titlevr: "",
        titlechavr: "",
        titlechapic: "",
        // 是否显示弹出层
        open: false,
        openvr: false,
        openchavr: false,
        openchapic: false,
        openPic: false,
        // 查询参数
        queryParamsvr: {
          pageNum: 1,
          pageSize: 10,
          constructionStrategyId: null,
          userId: null,
          state: null,
          vrUrl: null,
          vrZhuti: null,
          vrShouyeUrl: null
        },
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          constructionStrategyTitle: null,
          constructionStrategyGood: null,
          constructionStrategyCollection: null,
          constructionStrategyComment: null,
          strategyTheme: null,
          userId: null,
          strategyHabitable: null,
          strategyName: null,
          meters: null,
          price: null,
          strategyStyle: null,
          priceYusuan: null,
          fangshi: null,
          shipinUrl: null,
          strategyType: null,
          strategyZhutuUrl: null
        },
        InfoImgList:[],
        InfoImgListVR:[],
        InfoImgListpic:[],
        // 表单参数
        form: {},
        formPic: {
          constructionStrategyId:0
        },
        formvr: {
          constructionStrategyId:0
        },
        // 表单校验
        rulesvr: {},
        rules: {

        }
      };

    },

    created() {
      this.getList();
      this.getSupplierList();
    },

    methods: {

      getChildrenStatus: function(data){ // 实时更新子组件的变化
        this.form.constructionStrategyTitle = data
      },

      beforeUpload2(file){
        console.log(file);
        if (file.type.indexOf("video/") == -1) {
          this.msgError("文件格式错误，请上传文件类型,如：MP4后缀的文件。");
        } else {
          const reader = new FileReader();
          reader.readAsDataURL(file);
          reader.onload = () => {
            const a = {
              name:file.uid,
              url:reader.result,
            };
            this.fileList2.push(a);
          };
          let formData = new FormData();
          formData.append("carouselFile", file);
          // 上传
          upVideo(formData).then(res =>{
            console.log("***视频***"+res.imgUrl)
            this.form.shipinUrl = res.imgUrl;
          })
        }
      },

      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },


      getSupplierList(){
        selectSupplierList().then(response => {
          this.supplierList = response.data;
        })
      },


      // 覆盖默认的上传行为
      requestUpload() {
      },

      handleRemoveInfoImage(file, fileList){
        const picName = `${file.name}`;
        deleteDetailsImgByName(picName).then((res)=>{
          if(res.code == 200){
            this.formPic.picUrl = '';
            this.fileList=[];
          }
        });
      },

      handleRemoveInfoImageVR(){
        const picName = `${file.name}`;
        deleteDetailsImgByName(picName).then((res)=>{
          if(res.code == 200){
            this.titlevr.vrShouyeUrl = '';
            this.fileList=[];
          }
        });
      },

      handleRemoveInfoImagepic(){
        const picName = `${file.name}`;
        deleteDetailsImgByName(picName).then((res)=>{
          if(res.code == 200){
            this.titlevr.pictureUrl = '';
            this.fileList=[];
          }
        });
      },



      upload(param){
        let file = param.file;
        let fileType = file.type;
        let isLt2M = file.size / 1024 / 1024 < 500;
        if (!isLt2M) {
          this.$message.error("上传大小大小必须小于500M");
          this.fileList=[];
          return;
        }
        let form = new FormData();
        form.append("file", file);
        uploadImage(form).then((res)=>{
          if(res.code==200){
            this.form.strategyZhutuUrl = "http://51jhf.com/profile/xiazai/"+res.filePath;
          }
          // console.log(res);
        })
      },

      uploadVR(param){
        let file = param.file;
        let fileType = file.type;
        let isLt2M = file.size / 1024 / 1024 < 500;
        if (!isLt2M) {
          this.$message.error("上传大小大小必须小于500M");
          this.fileList=[];
          return;
        }

        let form = new FormData();
        form.append("file", file);
        uploadImage(form).then((res)=>{
          if(res.code==200){
            this.formvr.vrShouyeUrl = "http://51jhf.com/profile/xiazai/"+res.filePath;
          }
          // console.log(res);
        })
      },

      uploadpic(param){
        let file = param.file;
        let fileType = file.type;
        let isLt2M = file.size / 1024 / 1024 < 500;
        if (!isLt2M) {
          this.$message.error("上传大小大小必须小于500M");
          this.fileList=[];
          return;
        }

        let form = new FormData();
        form.append("file", file);
        uploadImagepic(form).then((res)=>{
          if(res.code==200){
            this.formPic.pictureUrl = "http://51jhf.com/profile/xiazai/"+res.filePath;
          }
          // console.log(res);
        })
      },





      beforeUpload(file) {
        if (file.type.indexOf("video/") == -1) {
          this.msgError("文件格式错误，请上传视频类型,如：mp4后缀的文件。");
        }else{
          let form = new FormData();
          form.append("videoFile", file);
          uploadVideo(form).then((res) =>{
            if(res.code == 200){
              this.form.shipinUrl = res.filePath;
            }else{
              this.$message({
                message: res.msg,
                type: 'error'
              });
            }
          })
        }
      },

      beforeRemoveInfo(file, InfoImgList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },

      beforeRemoveInfoVR(file, InfoImgList){
        return this.$confirm(`确定移除 ${file.name}？`);
      },
      beforeRemoveInfopic(file, InfoImgList){
        return this.$confirm(`确定移除 ${file.name}？`);
      },


      //
      //上传异常
      handleError(err, file, fileList){
        this.$message.error("上传失败");
      },
      handleErrorVR(err, file, fileList){
        this.$message.error("上传失败");
      },

      handleErrorpic(err, file, fileList){
        this.$message.error("上传失败");
      },


      /** 查询施工攻略列表 */
      getList() {
        this.loading = true;
        listStrategy(this.queryParams).then(response => {
          this.strategyList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 取消按钮
      cancelvr() {
        this.openvr = false;
        this.resetvr();
      },
      cancelPic(){
        this.openPic = false;
        this.resetPic();
      },

      resetPic() {
        this.formPic = {
          pictureId: null,
          pictureUrl: null,
          constructionStrategyId: null,
          userId: null
        };
        // this.resetForm("form");
      },

      // 表单重置
      reset() {
        this.form = {
          constructionStrategyId: null,
          constructionStrategySupplier: null,
          constructionStrategyTitle: null,
          constructionStrategyGood: null,
          constructionStrategyCollection: null,
          constructionStrategyComment: null,
          constructionStrategyTime: null,
          modifiedTime: null,
          strategyTheme: null,
          userId: null,
          strategyHabitable: null,
          strategyName: null,
          meters: null,
          price: null,
          strategyStyle: null,
          priceYusuan: null,
          fangshi: null,
          shipinUrl: null,
          strategyType: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.strategyId)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },

      handlevr(){
        this.openchavr = true;
        this.titlechavr ="查看VR";
        listVr(this.queryParamsvr).then(res=>{
          console.log("99999**********"+res)
          this.avrList = res.rows;
          this.totalvr = res.total;
          this.loading = false;
        })
      },
      handlepic(){
        this.openchapic = true;
        this.titlechapic ="查看全部图片";
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加施工攻略";
      },
      handleAddvr(row) {
        // this.resetvr();
        this.openvr = true;
        this.titlevr = "添加施工攻略vr";
        console.log("***row.constructionStrategyId***"+row.constructionStrategyId)

        this.formvr.constructionStrategyId=row.constructionStrategyId;
      },

      handleAddPic(row){
        this.openPic = true;
        this.titlePic = "添加施工攻略图片";
        this.formPic.constructionStrategyId=row.constructionStrategyId;
      },


      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const constructionStrategyId = row.constructionStrategyId || this.ids
        getStrategy(constructionStrategyId).then(response => {
          console.log(response.data)
          this.form = response.data;
          this.open = true;
          this.title = "修改施工攻略";
        });
      },
      submitFormvr() {
        // this.$refs["formvr"].validate(valid => {
        //   if (valid) {
        addVr(this.formvr).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增vr成功");
                this.openvr = false;
                this.getList();
              }
            });
        //   }
        // })
      },

      submitFormPic(){
        addPicture(this.formPic).then(response=>{
          if (response.code === 200) {
            this.msgSuccess("新增图片成功");
            this.openPic = false;
          }
        })
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.constructionStrategyId != null) {
              updateStrategy(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                }
              });
            } else {
              addStrategy(this.form).then(response => {
                console.log(this.form)
                if (response.code === 200) {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
                }
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const constructionStrategyIds = row.constructionStrategyId || this.ids;
        this.$confirm('是否确认删除施工攻略编号为"' + constructionStrategyIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delStrategy(constructionStrategyIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有施工攻略数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportStrategy(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
      }
    }

};
</script>
